import request, { requestHttp } from "@/utils/request";
import { ResPage } from "@/api/types";
import { ReqEvalReviewerParams } from "@/api/evaluation/reviewer";

export interface EvalScoreDetails {
  /**
   * 分数
   */
  score: number;

  /**
   * 评价人
   */
  reviewerName: string;

  /**
   * 评价人id
   */
  reviewerUserId: number;

  /**
   * 被评价人
   */
  evaluatedName: string;

  /**
   * 被评价人id
   */
  evaluatedId: number;

  /**
   * 评价人角色
   */
  reviewerRole: string;

  /**
   * 评价人角色id
   */
  reviewerRoleId: number;

  /**
   * 评价题目名称
   */
  formItemName: string;
}

export interface PageParam {
  current: number;
  size: number;
  formKey: string;
}

/**
 * 查询评价分数详情
 */
export function listEvalScoreDetails(params: PageParam) {
  return requestHttp.get<ResPage<EvalScoreDetails>>("/form/eval/score/item/page", params);
}

/**
 * 查询评价分数汇总
 * @param params   分页
 */
export function listEvalScoreSummary(params: PageParam) {
  return requestHttp.get<ResPage<EvalScoreDetails>>("/form/eval/score/summary/page", params);
}

/**
 * 汇总分数导出
 * @param param
 */
export function exportScoreSummary(param: ReqEvalReviewerParams) {
  return request({
    url: "/form/eval/score/summary/export",
    method: "get",
    params: param,
    responseType: "blob"
  });
}

/**
 * 分析明细导出
 * @param param
 */
export function exportScoreDetails(param: ReqEvalReviewerParams) {
  return request({
    url: "/form/eval/score/item/export",
    method: "get",
    params: param,
    responseType: "blob"
  });
}

/**
 * 下载二维码
 */

export function exportQrcode(param: ReqEvalReviewerParams) {
  return request({
    url: "/form/eval/reviewer/exportQrcode",
    method: "get",
    params: param,
    responseType: "blob"
  });
}
